﻿using System.Collections.Generic;
using Tp.Dto.Allgemein;
using Tp.Dto.Stammdaten;
using Tp.Interfaces.Services;
using Tp.Services.DataLayer;
using Tp.Services.Manager;

namespace Tp.Services
{
	  public class OrganisationService : IOrganisationService
	  {
			public OrganisationDto LoadOrganisation(int organisationID)
			{
				  using (OrganisationDataLayer dl = CreateOrganisationDataLayer())
				  {
						return dl.LoadOrganisation(organisationID);
				  }
			}

			public List<OrganisationDto> LoadOrganisations()
			{
				  List<OrganisationDto> myList = new List<OrganisationDto>();
				  OrganisationDto myOrg = LoadOrganisation(1);
				  OrganisationDto myOrg2 = LoadOrganisation(2);
                  
				  myList.Add(myOrg);
				  myList.Add(myOrg2);
				  return myList;
			}

			public void SaveOrganisation(OrganisationDto myOrg)
			{
				  //toDo Speichere Daten in Db
			}

			private static OrganisationDataLayer CreateOrganisationDataLayer()
			{
				  return (DataManager.CreateDataLayer(typeof(OrganisationDataLayer)) as OrganisationDataLayer);
			}
	  }
}
